package paul.aurebesh.markerHunt;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;

import android.opengl.GLSurfaceView;
import android.opengl.GLU;

public class MarkerRenderer implements GLSurfaceView.Renderer{

	MarkerRenderer()
	{
		
	}
	
    public void onSurfaceChanged(GL10 gl, int width, int height) {
    	if(height == 0) { 						//Prevent A Divide By Zero By
			height = 1; 						//Making Height Equal One
		}
    	
    	gl.glViewport(0, 0, width, height);		//Reset The Current Viewport
    	gl.glMatrixMode(GL10.GL_PROJECTION);	//Select The Projection Matrix
    	gl.glLoadIdentity();					//Reset The Projection Matrix
    	
		//Calculate The Aspect Ratio Of The Window
    	GLU.gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 100.0f);

		gl.glMatrixMode(GL10.GL_MODELVIEW); 	//Select The Modelview Matrix
		gl.glLoadIdentity(); 					//Reset The Modelview Matrix
    }

    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    	gl.glDisable(GL10.GL_DITHER);
    	gl.glEnable(GL10.GL_TEXTURE_2D);
    	gl.glEnable(GL10.GL_CULL_FACE);
    	gl.glShadeModel(GL10.GL_SMOOTH);
    	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    	gl.glDisable(GL10.GL_DEPTH_TEST);
    	gl.glEnable(GL10.GL_BLEND);
    	gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    	gl.glDisable(GL10.GL_LIGHTING);
    	gl.glEnable(GL11.GL_POINT_SPRITE_OES);
    	gl.glPointSizex(20);

    	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
                GL10.GL_FASTEST);
    }
    
    public void onDrawFrame(GL10 gl) {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

        gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();					//Reset The Current Modelview Matrix
		gl.glTranslatef(0, 0, -3.0f);
		
    }
}
